package com.jtbd.controller;

import com.jtbd.constants.ResponseCodeEnum;
import com.jtbd.dto.request.CustomerItemCreateHttpDto;
import com.jtbd.dto.request.CustomerItemHttpDto;
import com.jtbd.dto.result.ResponseBaseData;
import com.jtbd.service.CustomerManagementService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@Tag(name = "客户管理接口")
@RequestMapping("/customer")
public class CustomerManagementController {
    @Resource
    private CustomerManagementService customerManagementService;

    @PostMapping("/addCustomer")
    @Operation(summary = "添加客户")
    public ResponseBaseData<Long> addCustomer(@RequestBody CustomerItemCreateHttpDto customers) {
        Long customerId = customerManagementService.addCustomer(customers);
        if (!ObjectUtils.isEmpty(customerId)) {
            return ResponseBaseData.success(customerId);
        }
        return ResponseBaseData.error(ResponseCodeEnum.ERROR.getCode(), "添加客户失败");
    }

    @GetMapping("/getCustomers")
    @Operation(summary = "获取客户")
    public ResponseBaseData<CustomerItemCreateHttpDto> getCustomers() {

        return ResponseBaseData.error(ResponseCodeEnum.ERROR.getCode(), "获取客户失败");
    }

}
